package com.air.repo.design.pattern.singleton;

import java.util.concurrent.TimeUnit;

/**
 * Place Function on Here:
 *
 * @author yh 2018/7/12 13:36
 * @since: Jdk 1.8
 */
public class Singleton1 {

    private static Singleton1 instance;

    private Singleton1() {}

    public static Singleton1 getInstance() {
        if (instance == null) {
            instance = new Singleton1();

        }
        return instance;
    }

    public synchronized static Singleton1 getInstance1() {
        if (instance == null) {
            instance = new Singleton1();
        }
        return instance;
    }


    public static Singleton1 getInstance2() {
        synchronized (Singleton1.class) {
            if (instance == null) {
                instance = new Singleton1();
            }
        }
        return instance;
    }




}
